import { ref, toRaw } from 'vue';
export const reload = ref<boolean>(false);
export const buildDepts = (depts) => {
  depts.forEach((data) => {
    if (data.children) {
      buildDepts(data.children);
    }
    if (data.leaf) {
      data.isLeaf = data.leaf;
    }
  });
};

export const currentId = ref(null);
export const checkedKeys = ref<any>([]);
export const showButton = ref(false);
export function customRow(record) {
  return {
    onClick: () => {
      currentId.value = record.id;
      checkedKeys.value = toRaw(record.menus).map((item) => {
        return item.id;
      });
      showButton.value = true;
    },
  };
}
export function setRowClassName(record): string {
  return record.id === currentId.value ? 'clickRowStyl' : '';
}
